﻿using Stylet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;

namespace LearnWPF.Pages
{
    public class PageControlsViewModel : Screen
    {
        protected override void OnInitialActivate()
        {
            base.OnInitialActivate();
            ClockTime = DateTime.Now;

            Task.Run(() =>
            {
                while (true)
                {
                    Thread.Sleep(1000);
                    if (!IsManual)
                    {
                        ClockTime = DateTime.Now;
                    }
                }
            });
        }

        public bool IsManual { get; set; }

        public int Hour { get; set; } = 1;
        public int Minute { get; set; } = 2;
        public int Second { get; set; } = 3;

        public DateTime ClockTime { get; set; }

        public void SetTime()
        {
            DateTime now = DateTime.Now;
            ClockTime = new DateTime(now.Year, now.Month, now.Day, Hour, Minute, Second);
        }

        public void ButtonOpenClick()
        {
            MessageBox.Show("ButtonOpenClick");
        }
    }
}
